@extends('admin.layout')
@section('title','查询')
@section('body')
    <div class="container1">
        <div id="search" style="height:63px;">
            <div id="search" style="height:63px;">
                <blockquote class="layui-elem-quote" style="font-size: 14px">
                    <form action="" method="post" class="layui-form">
                        <div class="layui-form-item">
                            <div  class="layui-inline">
                                <label class="layui-form-label">排序</label>
                                <div class="layui-input-inline">
                                    <select id="sort" lay-filter="class" lay-verify="" lay-search>
                                        <option value=1 selected>正序</option>
                                        <option value=2>反序</option>
                                    </select>
                                </div>
                            </div>

                            <div  class="layui-inline">
                                <div class="btn btn-info " onclick="sort()">查询</div>
                            </div>

                            <div  class="layui-inline">
                                <input type="text" id="liketime" class="form-control">
                                <span>年：2017/  月：2017/08/  日：2017/08/01</span>
                            </div>
                            <div  class="layui-inline">
                                <div class="btn btn-info " onclick="liketime()">查询</div>
                            </div>

                            <div  class="layui-inline">
                                订单数量:@{{num.num}},销售额:@{{num.total}}。
                            </div>

                            <div  class="layui-inline">
                                <div class="btn btn-info " onclick="this_all()">查看所有分销商</div>
                            </div>
                        </div>
                        <input type="reset" id="reset" value="" style="display:none;">
                    </form>
                </blockquote>
            </div>
            <table class="layui-table " >
                <colgroup>

                </colgroup>
                <thead>
                <tr>
                    <th>id</th>
                    <th>名称</th>
                    <th>订单数</th>
                    <th>销售额</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="value in data.Data">
                    <td>@{{value.id}}</td>
                    <td>@{{value.name}}</td>
                    <td>@{{value.num}}</td>
                    <td>@{{value.total}}</td>
                    <td>

                        <input type="button" class="btn btn-danger" @click="this_order(value.id)" value="查看订单">
                        <input type="button" class="btn btn-info" @click="all_son( value.id )" value="查看店铺">
                    </td>
                </tr>
                </tbody>
            </table>
            <div id="page"></div>
        </div>
        @endsection
        @section('js')
            <script src="{{asset('js/vue.min.js')}}"></script>
            <script>
                @if(Session::has('message'))
layer.msg("{{Session::get("message")}}");
                        {{Session::forget('message')}}
                        @endif

                var vm=new Vue({
                        el:".container1",
                        data:{
                            count:1,
                            num:{},
                            data:{}

                        },
                        mounted:function () {
                            layui.use(['laypage', 'layer','form'], function() {
                                var laypage = layui.laypage,layer = layui.layer,form = layui.form();
                                var sort = $("#sort").val();
                                laypage({
                                    cont: 'page'
                                    ,pages: 10
                                    ,skin: '#1E9FFF'
                                    ,groups: 0
                                    ,first: false
                                    ,last: false,
                                    skip:true
                                    ,jump:function (obj,first) {
                                        if(first){
                                            $.get({
                                                url:'http://egui.gebixianxiang.com:8081/BGoods/NewData/GroupsByAdmin?classid={{$id}}&sort='+sort,
                                                data:{'pages':1},
                                                success:function (res) {
                                                    vm.data=res;
                                                    vm.num=res.Num;
                                                    obj.pages=res.Pages;
                                                }
                                            })
                                        }else{
                                            $.get({
                                                url:'http://egui.gebixianxiang.com:8081/BGoods/NewData/GroupsByAdmin?classid={{$id}}&sort='+sort,
                                                data:{'pages':obj.curr},
                                                success:function (res) {
                                                    vm.data=res;
                                                }
                                            })
                                        }
                                    }
                                });

                            });
                        },
                        filters:{
                            val :function (val) {
                                if(val==0){
                                    return val='已上架';
                                }
                                if(val==3){
                                    return val='已下架'
                                }
                            }
                        }

                    });



                function this_order(id) {
                    window.location.href="{{url('count/this_order')}}"+"?type=1&id="+id;
                }
                
                function this_all() {
                    window.location.href="{{url('count/this_all')}}"+"?type=1"
                }


                function sort() {
                    layui.use(['laypage', 'layer','form'], function() {
                        var laypage = layui.laypage, layer = layui.layer, form = layui.form();
                        var sort = $("#sort").val();
                        laypage({
                            cont: 'page'
                            ,pages: 10
                            ,skin: '#1E9FFF'
                            ,groups: 0
                            ,first: false
                            ,last: false,
                            skip:true
                            , jump: function (obj, first) {
                                if (first) {
                                    $.get({
                                        url: 'http://egui.gebixianxiang.com:8081/BGoods/NewData/GroupsByAdmin?classid={{$id}}&pages=1&sort=' + sort,
                                        data: {'pages': 1},
                                        success: function (res) {
                                            vm.data=res;
                                            vm.num=res.Num;
                                            obj.pages=res.Pages;
                                        }
                                    })
                                } else {
                                    $.get({
                                        url: 'http://egui.gebixianxiang.com:8081/BGoods/NewData/GroupsByAdmin?classid={{$id}}&pages=1&sort=' + sort,
                                        data: {'pages': obj.curr},
                                        success: function (res) {
                                            vm.data=res
                                        }
                                    })
                                }
                            }
                        });
                    })
                }

                function all_son(id) {
                    window.location.href="{{url('count/ask3')}}"+"?id="+id;
                }


                function liketime() {
                    layui.use(['laypage', 'layer','form'], function() {
                        var laypage = layui.laypage, layer = layui.layer, form = layui.form();
                        var sort = $("#sort").val();
                        var liketime = $("#liketime").val();
                        laypage({
                            cont: 'page'
                            ,pages: 10
                            ,skin: '#1E9FFF'
                            ,groups: 0
                            ,first: false
                            ,last: false,
                            skip:true
                            , jump: function (obj, first) {
                                if (first) {
                                    $.get({
                                        url: 'http://egui.gebixianxiang.com:8081/BGoods/NewData/GroupsByAdmin?classid={{$id}}&pages=1&sort=' + sort+"&liketime="+liketime,
                                        data: {'pages': 1},
                                        success: function (res) {
                                            vm.data=res;
                                            vm.num=res.Num;
                                            obj.pages=res.Pages;
                                        }
                                    })
                                } else {
                                    $.get({
                                        url: 'http://egui.gebixianxiang.com:8081/BGoods/NewData/GroupsByAdmin?classid={{$id}}&pages=1&sort=' + sort+"&liketime="+liketime,
                                        data: {'pages': obj.curr},
                                        success: function (res) {
                                            vm.data=res
                                        }
                                    })
                                }
                            }
                        });
                    })
                }
            </script>

@endsection
